import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { IPSSysSFPlugin } from './ipssys-sfplugin';
import { IPSSysSequence } from './ipssys-sequence';
import { IPSSystemModule } from '../system/ipssystem-module';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysSequenceImpl extends PSModelObjectImpl implements IPSSysSequence {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected extformatparams: string[] | null = null;

  getExtFormatParams(): string[] | null {
    if (this.extformatparams == null) {
      const value = this.M.extFormatParams;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: string[] = [];
      for (let i = 0; i < arrayNode.length; i++) {
        list.push(arrayNode[i]);
      }
      this.extformatparams = list;
    }
    return this.extformatparams;
  }

  get extFormatParams(): string[] | null {
    return this.getExtFormatParams();
  }

  protected keypsdefield: IPSDEField | null = null;

  getKeyPSDEField(): IPSDEField | null {
    if (this.keypsdefield != null) return this.keypsdefield;
    const value = this.M.getKeyPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.keypsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.keypsdefield;
  }

  get keyPSDEField(): IPSDEField | null {
    return this.getKeyPSDEField();
  }

  getKeyPSDEFieldMust(): IPSDEField {
    const value = this.getKeyPSDEField();
    if (value == null) {
      throw new Error('未指定标识存储属性');
    }
    return value;
  }

  get maxValue(): number {
    return this.M.maxValue;
  }

  get memo(): string {
    return this.M.memo;
  }

  get minValue(): number {
    return this.M.minValue;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后端模板插件对象');
    }
    return value;
  }

  protected pssystemmodule: IPSSystemModule | null = null;

  getPSSystemModule(): IPSSystemModule | null {
    if (this.pssystemmodule != null) return this.pssystemmodule;
    const value = this.M.getPSSystemModule;
    if (value == null) {
      return null;
    }
    this.pssystemmodule = this.getPSModel4('system.IPSSystemModule', value, 'getPSSystemModule') as IPSSystemModule;
    return this.pssystemmodule;
  }

  get psSystemModule(): IPSSystemModule | null {
    return this.getPSSystemModule();
  }

  getPSSystemModuleMust(): IPSSystemModule {
    const value = this.getPSSystemModule();
    if (value == null) {
      throw new Error('未指定系统模块');
    }
    return value;
  }

  get sequenceFormat(): string {
    return this.M.sequenceFormat;
  }

  get sequenceTag(): string {
    return this.M.sequenceTag;
  }

  get sequenceTag2(): string {
    return this.M.sequenceTag2;
  }

  get sequenceType(): 'DB' | 'DE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.sequenceType;
  }

  get timeFormat(): string {
    return this.M.timeFormat;
  }

  protected timepsdefield: IPSDEField | null = null;

  getTimePSDEField(): IPSDEField | null {
    if (this.timepsdefield != null) return this.timepsdefield;
    const value = this.M.getTimePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.timepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.timepsdefield;
  }

  get timePSDEField(): IPSDEField | null {
    return this.getTimePSDEField();
  }

  getTimePSDEFieldMust(): IPSDEField {
    const value = this.getTimePSDEField();
    if (value == null) {
      throw new Error('未指定时间存储属性');
    }
    return value;
  }

  protected typepsdefield: IPSDEField | null = null;

  getTypePSDEField(): IPSDEField | null {
    if (this.typepsdefield != null) return this.typepsdefield;
    const value = this.M.getTypePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.typepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.typepsdefield;
  }

  get typePSDEField(): IPSDEField | null {
    return this.getTypePSDEField();
  }

  getTypePSDEFieldMust(): IPSDEField {
    const value = this.getTypePSDEField();
    if (value == null) {
      throw new Error('未指定类型存储属性');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  protected valuepsdefield: IPSDEField | null = null;

  getValuePSDEField(): IPSDEField | null {
    if (this.valuepsdefield != null) return this.valuepsdefield;
    const value = this.M.getValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.valuepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.valuepsdefield;
  }

  get valuePSDEField(): IPSDEField | null {
    return this.getValuePSDEField();
  }

  getValuePSDEFieldMust(): IPSDEField {
    const value = this.getValuePSDEField();
    if (value == null) {
      throw new Error('未指定值存储属性');
    }
    return value;
  }

  get cls(): string {
    return 'PSSysSequenceImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'res.IPSSysSequence') return true;
    return super.instanceof(cls);
  }
}
